﻿using System;
using System.Data;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BaseData;
using BaseData.UI;
using TaxBiz.SysConfig;

namespace Admin.SysConfig
{
    public partial class TaxList : BaseCommon.BasePage
    {
        protected TaxsBiz tb = new TaxsBiz();
        protected string pageUrl = string.Empty;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!HasPower())
            {
                Jscript.AlertAndGoBack("您权限不足，不能操作");
                return;
            }
            pageUrl = Request.Url.AbsolutePath;
            string action = PageContext.GetRequest("action");
            if (!string.IsNullOrEmpty(action))
            {
                if (action.Trim().ToLower() == "stop")
                {
                    Delete();
                }
                return;
            }
            this.BindData();
        }

        //删除数据
        protected bool Delete()
        {
            string strID = PageContext.GetRequest("ID");
            string succPageUrl = Server.UrlDecode(Request["pageurl"]);
            int ID = 0;
            int.TryParse(strID, out ID);
            if (ID == 0)
            {
                Jscript.AlertAndGoBack("参数错误");
                return false;
            }
            bool isSucc = tb.Delete(ID, UserLogin);
            if (!isSucc)
            {
                Jscript.AlertAndGoBack("删除税种失败");
                return false;
            }
            Jscript.AlertAndRedirect("删除税种成功", succPageUrl);
            return true;
        }

        protected void BindData()
        {
            this.rptDataList.DataSource = tb.GetList();
            this.rptDataList.DataBind();
        }
    }
}